after pay update PackGoodsSaleInfo

FFIB 5 年之前
父節點
當前提交
bf09b11e80
共有 4 個文件被更改,包括 8 次插入174 次删除
  1. 1 1
      goods/models.py
  2. 0 1
      kodosale/settings.py
  3. 0 171
      kodosale/widgets.py
  4. 7 1
      pay/views.py

+ 1 - 1
goods/models.py

@@ -63,7 +63,7 @@ class PackInfo(BaseModelMixin):
63 63
     def data(self):
64 64
         return {
65 65
             'title': self.title,
66
-            'expired_at': tc.local_string(self.expired_at, format='%Y-%m-%d %H:%M'),
66
+            'expired_at': tc.local_string(local_dt=self.expired_at, format='%Y-%m-%d %H:%M'),
67 67
             'pack_detail': self.pack_detail,
68 68
         }
69 69
 

+ 0 - 1
kodosale/settings.py

@@ -164,7 +164,6 @@ USE_TZ = True
164 164
 # https://docs.djangoproject.com/en/1.11/howto/static-files/
165 165
 
166 166
 STATICFILES_DIRS = (
167
-    os.path.join(BASE_DIR, "simditor", "static"),
168 167
     os.path.join(PROJ_DIR, 'static').replace('\\', '/'),
169 168
 )
170 169
 

+ 0 - 171
kodosale/widgets.py

@@ -1,171 +0,0 @@
1
-# -- coding: utf-8 --
2
-"""simditor widgets."""
3
-from __future__ import absolute_import
4
-
5
-from django import forms
6
-from django.conf import settings
7
-from django.core.exceptions import ImproperlyConfigured
8
-from django.core.serializers.json import DjangoJSONEncoder
9
-from django.template.loader import render_to_string
10
-from django.utils.encoding import force_text
11
-from django.utils.functional import Promise
12
-from django.utils.html import conditional_escape
13
-from django.utils.safestring import mark_safe
14
-
15
-
16
-try:
17
-    # Django >=2.1
18
-    from django.forms.widgets import get_default_renderer
19
-    IS_NEW_WIDGET = True
20
-except ImportError:
21
-    IS_NEW_WIDGET = False
22
-
23
-try:
24
-    # Django >=1.7
25
-    from django.forms.utils import flatatt
26
-except ImportError:
27
-    # Django <1.7
28
-    from django.forms.util import flatatt        # pylint disable=E0611, E0401
29
-
30
-
31
-class LazyEncoder(DjangoJSONEncoder):
32
-    """LazyEncoder."""
33
-
34
-    # pylint disable=E0202
35
-    def default(self, obj):
36
-        if isinstance(obj, Promise):
37
-            return force_text(obj)
38
-        return super(LazyEncoder, self).default(obj)
39
-
40
-
41
-JSON_ENCODE = LazyEncoder().encode
42
-
43
-
44
-FULL_TOOLBAR = [
45
-    'title', 'bold', 'italic', 'underline', 'strikethrough', 'fontScale',
46
-    'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link',
47
-    'image', 'hr', '|', 'indent', 'outdent', 'alignment', 'checklist',
48
-    'markdown', 'fullscreen'
49
-]
50
-
51
-DEFAULT_TOOLBAR = [
52
-    'title', 'bold', 'italic', 'underline', 'strikethrough', 'fontScale',
53
-    'color', '|', 'ol', 'ul', 'blockquote', 'table', '|', 'link',
54
-    'image', 'hr', '|', 'indent', 'outdent', 'alignment'
55
-]
56
-
57
-DEFAULT_CONFIG = {
58
-    'toolbar': DEFAULT_TOOLBAR,
59
-    'cleanPaste': True,
60
-    'tabIndent': True,
61
-    'pasteImage': True,
62
-    'upload': {
63
-        'url': '/',
64
-        'fileKey': 'file'
65
-    }
66
-}
67
-
68
-
69
-class SimditorWidget(forms.Textarea):
70
-    """
71
-    Widget providing Simditor for Rich Text Editing.abs
72
-    Supports direct image uploads and embed.
73
-    """
74
-    class Media:
75
-        """Media."""
76
-
77
-        css_list = [
78
-            'simditor/styles/simditor.min.css'
79
-        ]
80
-
81
-        if 'emoji' in settings.SIMDITOR_TOOLBAR:
82
-            css_list.append('simditor/styles/simditor-emoji.css')
83
-
84
-        if 'fullscreen' in settings.SIMDITOR_TOOLBAR:
85
-            css_list.append('simditor/styles/simditor-fullscreen.min.css')
86
-
87
-        if 'checklist' in settings.SIMDITOR_TOOLBAR:
88
-            css_list.append('simditor/styles/simditor-checklist.min.css')
89
-
90
-        if 'markdown' in settings.SIMDITOR_TOOLBAR:
91
-            css_list.append('simditor/styles/simditor-markdown.min.css')
92
-
93
-        css = {'all': tuple(settings.STATIC_URL + url for url in css_list)}
94
-
95
-        jquery_list = ['simditor/scripts/jquery.min.js',
96
-                       'simditor/scripts/module.min.js',
97
-                       'simditor/scripts/hotkeys.min.js',
98
-                       'simditor/scripts/uploader.min.js',
99
-                       'simditor/scripts/simditor.min.js']
100
-
101
-        if 'fullscreen' in settings.SIMDITOR_TOOLBAR:
102
-            jquery_list.append('simditor/scripts/simditor-fullscreen.min.js')
103
-
104
-        if 'checklist' in settings.SIMDITOR_TOOLBAR:
105
-            jquery_list.append('simditor/scripts/simditor-checklist.min.js')
106
-
107
-        if 'markdown' in settings.SIMDITOR_TOOLBAR:
108
-            jquery_list.append('simditor/scripts/marked.min.js')
109
-            jquery_list.append('simditor/scripts/to-markdown.min.js')
110
-            jquery_list.append('simditor/scripts/simditor-markdown.min.js')
111
-
112
-        if 'image' in settings.SIMDITOR_TOOLBAR:
113
-            jquery_list.append('simditor/scripts/simditor-dropzone.min.js')
114
-
115
-        if 'emoji' in settings.SIMDITOR_TOOLBAR:
116
-            jquery_list.append('simditor/scripts/simditor-emoji.js')
117
-
118
-        js = tuple(settings.STATIC_URL + url for url in jquery_list)
119
-
120
-        try:
121
-
122
-            js += (settings.STATIC_URL + 'simditor/simditor-init.js',)
123
-        except AttributeError:
124
-            raise ImproperlyConfigured("django-simditor requires \
125
-                     SIMDITOR_MEDIA_PREFIX setting. This setting specifies a \
126
-                    URL prefix to the ckeditor JS and CSS media (not \
127
-                    uploaded media). Make sure to use a trailing slash: \
128
-                    SIMDITOR_MEDIA_PREFIX = '/media/simditor/'")
129
-
130
-    def __init__(self, *args, **kwargs):
131
-        super(SimditorWidget, self).__init__(*args, **kwargs)
132
-        # Setup config from defaults.
133
-        self.config = DEFAULT_CONFIG.copy()
134
-
135
-        # Try to get valid config from settings.
136
-        configs = getattr(settings, 'SIMDITOR_CONFIGS', None)
137
-        if configs:
138
-            if isinstance(configs, dict):
139
-                self.config.update(configs)
140
-            else:
141
-                raise ImproperlyConfigured(
142
-                    'SIMDITOR_CONFIGS setting must be a dictionary type.')
143
-
144
-    def build_attrs(self, base_attrs, extra_attrs=None, **kwargs):
145
-        """
146
-        Helper function for building an attribute dictionary.
147
-        This is combination of the same method from Django<=1.10 and Django1.11
148
-        """
149
-        attrs = dict(base_attrs, **kwargs)
150
-        if extra_attrs:
151
-            attrs.update(extra_attrs)
152
-        return attrs
153
-
154
-    def render(self, name, value, attrs=None, renderer=None):
155
-        if value is None:
156
-            value = ''
157
-        final_attrs = self.build_attrs(self.attrs, attrs, name=name)
158
-
159
-        params = ('simditor/widget.html', {
160
-            'final_attrs': flatatt(final_attrs),
161
-            'value': conditional_escape(force_text(value)),
162
-            'id': final_attrs['id'],
163
-            'config': JSON_ENCODE(self.config)
164
-        })
165
-
166
-        if renderer is None and IS_NEW_WIDGET:
167
-            renderer = get_default_renderer()
168
-
169
-        data = renderer.render(*params) if IS_NEW_WIDGET else render_to_string(*params)
170
-
171
-        return mark_safe(data)

+ 7 - 1
pay/views.py

@@ -15,7 +15,7 @@ import json
15 15
 from functools import reduce
16 16
 
17 17
 from account.models import UserInfo
18
-from goods.models import PackInfo, PackGoodsInfo, GoodsInfo
18
+from goods.models import PackInfo, PackGoodsInfo, GoodsInfo, PackGoodsSaleInfo
19 19
 from kol.models import KOLInfo
20 20
 from pay.models import OrderInfo
21 21
 from utils.error.errno_utils import (PackStatusCode, KOLStatusCode, PackGoodsStatusCode, OrderStatusCode, UserStatusCode, 
@@ -128,6 +128,12 @@ def order_paid_success(order):
128 128
     order.pay_status = OrderInfo.PAID
129 129
     order.paid_at = tc.utc_datetime()
130 130
     order.save()
131
+    
132
+    PackGoodsSaleInfo.create(
133
+        pack_id=order.pack_id,
134
+        user_id=order.user_id,
135
+        saleinfo=order.goods_info
136
+    )
131 137
 
132 138
 
133 139
 def order_paid_fail(order):